package timing.ukulele.portal.convertor;

import com.alibaba.fastjson2.JSON;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

public class JsonStringListStringConverter {


    public static List<String> stringToListString(String str) {
        if (StringUtils.isEmpty(str))
            return new ArrayList<>(0);
        return JSON.parseArray(str, String.class);
    }

    public static String ListStringToString(List<String> list) {
        if (CollectionUtils.isEmpty(list))
            return "[]";
        return JSON.toJSONString(list);
    }
}
